<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
 
<ui:composition template="/template.xhtml">
	<ui:define name="content">
		<p:layoutUnit position="west" size="0" style="border:none;">  
	   	</p:layoutUnit>  
		  
	    <p:layoutUnit position="east" size="0" style="border:none;">  
	    </p:layoutUnit>
		    
		<p:layoutUnit position="center" styleClass="telaPrincipal"> 
		   	<h:form enctype="multipart/form-data">
		   	
				<p:panelGrid columns="1">
					<div align="center" id="divAvatar">
						<p:graphicImage id="photoPadrao" value="/images/avatar_padrao.jpg" width="100" height="150" cache="false" rendered="#{cadastroBean.streamContentAvatar == null}"/>
						<p:graphicImage id="photoAvatar" value="#{cadastroBean.streamContentAvatar}" width="100" height="150" cache="false" rendered="#{cadastroBean.streamContentAvatar != null}"/>
					</div>
					<p:commandButton id="modalUploadFoto" value="Carregar.." icon="ui-icon-circle-arrow-n" onclick="dialogUploadFoto.show();" />
					
					<p:outputLabel for="observacoes" value="Observações: " />
					<p:inputTextarea id="observacoes" value="#{cadastroBean.aluno.observacao}" rows="7" cols="120" />
					
					<p:outputLabel for="legenda-obs" value="Nome para o arquivo : " />
					<p:panelGrid columns="3">
						<p:inputText id="legenda-obs" value="#{cadastroBean.nomeArquivoObservacao}" size="40"/>
						<p:fileUpload value="#{cadastroBean.uploadFileObservacao}" mode="simple" />
						<p:commandButton value="Anexar Arquivo" actionListener="#{cadastroBean.handleFileUploadObservacao}" ajax="false"/>
					</p:panelGrid>
					<br />
					 
					<p:dataGrid id="tableArqObs" var="arquivo" value="#{cadastroBean.listaArquivosObservacao}" rendered="#{not empty cadastroBean.listaArquivosObservacao}"
						columns="1" paginatorAlwaysVisible="false" paginator="true" effect="true" 
						paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
						rowsPerPageTemplate="5, 10, 20">
						
						<div class="rowDataGridDocs">
							<p:outputLabel value="#{arquivo.nome}" styleClass="textDataGridDocs" />
							<div align="right" class="buttonDataGridDocs">
								<p:commandButton actionListener="#{cadastroBean.removerArquivoObservacao(arquivo)}" icon="ui-icon-trash" update="@([id$=tableArqObs])" 
										onclick="if (!confirm('Você deseja remover o item selecionado?')) return false;" ajax="false"/>
							</div>
						</div>
					</p:dataGrid>
					 
					<p:outputLabel for="informacoes" value="Informações: " />
					<p:inputTextarea id="informacoes" value="#{cadastroBean.aluno.informacao}" rows="7" cols="120" />
					
					<p:outputLabel for="legenda-inf" value="Nome para o arquivo : " />
					<p:panelGrid columns="3">
						<p:inputText id="legenda-inf" value="#{cadastroBean.nomeArquivoInformacao}" size="40"/>
						
						<p:fileUpload value="#{cadastroBean.uploadFileInformacao}" mode="simple" styleClass="fileUploadDocs"  />
						<p:commandButton value="Anexar Arquivo" actionListener="#{cadastroBean.handleFileUploadInformacao}" ajax="false" id="btnanexarinf" />
					</p:panelGrid>
				 	
					<p:dataGrid id="tableArqInf" var="arquivo" value="#{cadastroBean.listaArquivosInformacao}" rendered="#{not empty cadastroBean.listaArquivosInformacao}"
						columns="1" paginatorAlwaysVisible="false" paginator="true" effect="true" 
						paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
						rowsPerPageTemplate="5, 10, 20">
						
						<div class="rowDataGridDocs">
							<p:outputLabel value="#{arquivo.nome}" styleClass="textDataGridDocs" />
							<div align="right" class="buttonDataGridDocs">
								<p:commandButton actionListener="#{cadastroBean.removerArquivoInformacao(arquivo)}" icon="ui-icon-trash" update="@([id$=tableArqInf])" 
										onclick="if (!confirm('Você deseja remover o item selecionado?')) return false;" ajax="false"/>
							</div>
						</div>
					</p:dataGrid>
					
					<f:facet name="footer">
						<p:separator />
						<div align="right">
							<p:commandButton action="#{cadastroBean.cancelar}" value="Cancelar" icon="ui-icon-close" ajax="false" styleClass="buttonsFooter"/>
							<p:commandButton action="voltarMeio" value="Voltar" icon="ui-icon-seek-prev" ajax="false" styleClass="buttonsFooter"/>
							<p:commandButton action="#{cadastroBean.cadastrarAluno()}" value="Salvar" icon="ui-icon-disk" styleClass="buttonsFooter"
								 onstart="statusDialog.show()" oncomplete="statusDialog.hide()" update="@([id$=messagess])"/>
						</div>
					</f:facet>
				</p:panelGrid>
			</h:form>
			
		</p:layoutUnit>
		
		<!-- ADICIONAR FOTO PRINCIPAL -->
		<p:dialog widgetVar="dialogUploadFoto" modal="true" header="Upload Foto" width="auto" styleClass="fundoDialog"
			showEffect="fade" hideEffect="fade" resizable="false" id="uploadFotoDialog">
		
			<h:form id="formUploadAvatar" enctype="multipart/form-data">
				<p:fileUpload value="#{cadastroBean.uploadFileAvatar}" mode="simple" />
				<div align="right" class="buttonDataGridDocs">
					<p:commandButton value="Anexar" actionListener="#{cadastroBean.handleFileUploadAvatar}" oncomplete="dialogUploadFoto.hide()" ajax="false"/>
				</div>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
</html>